package com.newer.textdbnotepad.sdk

import javax.inject.Inject
import javax.inject.Singleton

/**
 * 安全api仓库
 * 对内容进行加解密
 * */
@Singleton
class SecurityApiRepository @Inject constructor(private val apiInterface: ApiInterface,private val securityInterface: SecurityInterface){
    /**获取记录*/
    suspend fun getRecord(recordKey: String): String{
        val encryptedContent = apiInterface.getRecord(recordKey)
        return securityInterface.decode(encryptedContent)
    }

    /**创建, 更新记录*/
    suspend fun updateRecord(recordKey: String, value: String): UpdateResponse{
        val encryptedValue = securityInterface.encode(value)
        return apiInterface.updateRecord(recordKey, encryptedValue)
    }

}